package com.lonwin.inspectionmanagement.mvp.ui.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lonwin.inspectionmanagement.R;
import com.lonwin.inspectionmanagement.app.utils.DataUtil;
import com.lonwin.inspectionmanagement.app.utils.TimeUtils;
import com.lonwin.inspectionmanagement.mvp.model.entity.bean.SortOutBean;
import com.lonwin.inspectionmanagement.mvp.ui.activity.CruiseLocusActivity;

import java.util.List;

public class SortOutRecordItemItem2Adapter extends BaseQuickAdapter<SortOutBean.DataBean.RecordsBean.XcpathTempsBean,BaseViewHolder> {
    public SortOutRecordItemItem2Adapter(@Nullable List<SortOutBean.DataBean.RecordsBean.XcpathTempsBean> data) {
        super(R.layout.sortout_record_item_item_item2,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SortOutBean.DataBean.RecordsBean.XcpathTempsBean item) {
        helper.setText(R.id.sortout_record_item_item_item2_startAdd,"起点："+(item.getStartaddr()==null?"--":item.getStartaddr()))
                .setText(R.id.sortout_record_item_item_item2_endAdd,"终点："+(item.getEndaddr()==null?"--":item.getEndaddr()))
                .setText(R.id.sortout_record_item_item_item2_time,TimeUtils.dateForStr(item.getEndtm()).substring(5,19));
//                .setText(R.id.sortout_record_item_item_item2_time,TextUtils.isEmpty(item.getTm())?"暂无巡河时间":DataUtil.formtTime(Integer.parseInt(item.getTm())));
           if (item.getOpened()==0)
           {
               helper.<TextView>getView(R.id.sortout_record_item_item_item2_edit).setText("编辑");
               helper.<TextView>getView(R.id.sortout_record_item_item_item2_usered).setVisibility(View.VISIBLE);
               helper.setText(R.id.sortout_record_item_item_item1_statue,"未提交");
               helper.<TextView>getView(R.id.sortout_record_item_item_item1_statue).setBackgroundResource(R.drawable.listbutton_gray_bg_select);
               helper.<TextView>getView(R.id.sortout_record_item_item_item2_usered).setOnClickListener(new View.OnClickListener() {
                   @Override
                   public void onClick(View v) {
                       CruiseLocusActivity.startCruiseLocusActivity(mContext,item.getGjid(),CruiseLocusActivity.Type.PUB,"提交轨迹");
                   }
               });
               helper.<TextView>getView(R.id.sortout_record_item_item_item2_edit).setOnClickListener(new View.OnClickListener() {
                   @Override
                   public void onClick(View v) {
//                       CruiseLocusActivity.startCruiseLocusActivity(mContext,item.getGjid(),item.getOpened()==0?CruiseLocusActivity.Type.PUB:CruiseLocusActivity.Type.LOOK,item.getOpened()==0?"提交轨迹":"查看轨迹");
                       CruiseLocusActivity.startCruiseLocusActivity(mContext,item.getGjid(),CruiseLocusActivity.Type.EDIT,"编辑轨迹");

                   }
               });
           }else {
               helper.<TextView>getView(R.id.sortout_record_item_item_item2_edit).setText("查看");
               helper.<TextView>getView(R.id.sortout_record_item_item_item2_usered).setVisibility(View.GONE);
               helper.setText(R.id.sortout_record_item_item_item1_statue,"已提交");
               helper.<TextView>getView(R.id.sortout_record_item_item_item1_statue).setBackgroundResource(R.drawable.listbutton_blue_bg_select);
               helper.<TextView>getView(R.id.sortout_record_item_item_item2_edit).setOnClickListener(new View.OnClickListener() {
                   @Override
                   public void onClick(View v) {
//                       CruiseLocusActivity.startCruiseLocusActivity(mContext,item.getGjid(),item.getOpened()==0?CruiseLocusActivity.Type.PUB:CruiseLocusActivity.Type.LOOK,item.getOpened()==0?"提交轨迹":"查看轨迹");
                       CruiseLocusActivity.startCruiseLocusActivity(mContext,item.getGjid(),CruiseLocusActivity.Type.LOOK,"查看轨迹");

                   }
               });

           }

    }
}
